package com.example.aidemo.converter;

import org.commonmark.node.Document;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;

public class Markdown2Html {

    /**
     * markdown字符串转HTML字符串
     * @param markdownText
     * @return
     */
    public static String markdown2Html(String markdownText) {
        Parser parser = Parser.builder().build();
        Document document = (Document) parser.parse(markdownText);
        HtmlRenderer renderer = HtmlRenderer.builder().build();
        String htmlText = renderer.render(document);
        return htmlText;
    }
}
